home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / ISBN.DMO < prev    next >
Text File  |  1996-07-04  |  5KB  |  89 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   ISBN    .DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18. '.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
  19. ' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
  20.  
  21. $INCLUDE "DAS-NB01.INC"
  22. COLOR 7,0
  23. CLS
  24.  
  25. ? "┌─────────────────────────────────────────────────────────────────────────────
  26. ? "│  ISBNmask ( NewMask$ )
  27. ? "│ fISBN%    ( ISBN$    )
  28. ? "│ fISBNck%  ( ISBN$    )
  29. ? "├─────────────────────────────────────────────────────────────────────────────
  30. ? "│ ISBNmask works with fISBN% and provides it with your preferred display style.
  31. ? "│ If you are going to re-format all ISBNs then you need to call it first then
  32. ? "│ use fISBN% to both check and reformat ISBN$.
  33. ? "│ fISBNck% only checks ISBN$ for correctness and does not re-format the STR.
  34. ? "├─────────────────────────────────────────────────────────────────────────────
  35. ? "│ Intl Sadistic Book Numbers consist of:   The dashes separate:
  36. ? "│   9 numbers                                1 the country
  37. ? "│   3 dashes                                 2 the publisher
  38. ? "│   1 check digit: 0123456789X               3 the publisher's book N°
  39. ? "│                                            4 the check digit
  40. ? "│ The problem comes in the fact that the country number, publisher number,
  41. ? "│ and book number can be of any length! Only the check-digit is a constant of
  42. ? "│ 1 digit (or an X). To be 100% correct you cannot reformat the ISBNs & should
  43. ? "│ require your users to input the dashes but, as I found out, most users (even
  44. ? "│ the pros) prefer the ISBNs to be formatted the same and forget the rest.
  45. ? "└─────────────────────────────────────────────────────────────────────────────
  46.  
  47. ISBNmask "##-##-#####-#"           '│ set the format mask
  48. Good$ = "0174433042"               '│ this is a good ISBN
  49. Bad$  = "0174333042"               '│ this one has a typo error
  50.                                    '│
  51. Ok% = fISBN%( Good$ )              '│ GOOD ONE
  52. PRINT Good$;                       '│
  53. IF NOT Ok% THEN PRINT " NOT";      '│
  54. PRINT " OK"                        '│
  55.                                    '│
  56. Ok% = fISBN%( Bad$ )               '│ BAD ONE
  57. PRINT Bad$;                        '│   note that the string has NOT been
  58. IF NOT Ok% THEN PRINT " NOT";      '│   reformatted as it is incorrect
  59. PRINT " OK"                        '│
  60.                                    '│
  61.  
  62. $if 0
  63. A further note here:
  64.  
  65.   In all fairness, ISBNs have been around longer than computers so they were
  66. created a bit illogically. There, also, wasn't much room for expansion of
  67. countries and publishers. As a point of interest 01 is England and 7 is/was
  68. Nelson Publishing and my clients preferred 017-44-3304-2 which is totally out
  69. of sync with all the rules but most of today's products are in the 440,000
  70. range and they tended to work with only the "3304". The program doesn't care
  71. what style the number is in as it ignored everything except the numbers and
  72. if the check digit "2" was correct then it was happy. As only the people in
  73. the Nelson office used/uses the program & print-outs it was more efficient to
  74. put the ISBNs in a format that the humans used than to enforce an unnecessary
  75. rule.
  76.  
  77. The purpose of this discussion is more important than the discussion itself.
  78.  
  79.     1) don't impose unnecessary "rules" on your users as the computer
  80.        usually doesn't care one way or the other
  81.  
  82.     2) most account numbers today have a check digit
  83.        This includes Banks, credit cards, stock numbers, etc. so when
  84.        you have to work with them find out the algorithm being used
  85.        and incorporate it into your program then check all incoming
  86.        data. This saves hours and hours of human down-time looking for
  87.        some obscure error!
  88. $endif
  89.